/*
 * 解析服务/订单状态码为界面显示的文字
 * @obj:接口返回的单条记录
 * sc_type：服务组合名
 * sc_status：服务组合状态
 * current_order_type：订单类型名称
 * current_order_status：订单状态
 * text：服务单状态(用于ui界面显示)
 * evaluation-*权限控制，如：evaluation-service服务组，evaluation-approve医生组
 * target_sc_status:服务组合状态
 * target_order_status：订单（服务单）状态
 * 
 * 注意：使用此工具解析code时，为了更方便的保留原有字段，规定解析后的字段名为原有字段名后加_text,
 * 界面显示的的即位该字段，所以在数据模型中，如果使用了此工具，需要在该field的tableName字段后
 * 加_text，如：sc_status => sc_status_text
 * */
function parseFn(obj) {

	var res = {}
	switch(Number(obj.sc_type)) {
		case 2:
			res.sc_type_text = '咨询挂号服务'
			break;
	}
	res['evaluation-approve'] = {
		text: '该服务单不需要您进一步操作。'
	}
	switch(Number(obj.sc_status)) {
		case 20:
			res.sc_status_text = '诊前评估'
			switch(Number(obj.current_order_status)) {
				case 10:
					res.current_order_status_text = '已提交'
					res['evaluation-service'] = {
						text: '患者已提交评估表，如果资料齐全，请选择“资料齐全，指派给医生审核”；如果资料不齐全，请选择“评估表不通过”',
						option: [{
							type: 'radio',
							label: '资料齐全，指派给医生审核',
							value: {
								target_sc_status: 20,
								target_order_status: 11
							},
							extra: [{
								type: 'select',
								rules: ['require'],
								placeholder: '请选择医生审核'
							}]
						}, {
							type: 'radio',
							label: '评估表不通过',
							value: {
								target_sc_status: 20,
								target_order_status: -11
							},
							extra: [{
								type: 'select',
								rules: ['require'],
								placeholder: '请选择不通过原因'
							}, {
								type: 'textarea',
								placeholder: '请详细说明'
							}]
						}]
					}
					res['evaluation-approve'] = {
						text: '该服务单不需要您进一步操作。'
					}
					res.text = '就诊评估已提交'
					break;
				case 11:
					res.current_order_status_text = '待确认'
					res['evaluation-service'] = {
						text: '该服务单正在等待医生审核',
						option: [{
							type: 'radio',
							value: {
								target_sc_status: 20,
								target_order_status: 12
							},
							label: '确认患者可以挂号就诊'
						}, {
							type: 'radio',
							label: '指派给另一名医生审核',
							value: {
								target_sc_status: 20,
								target_order_status: 11
							},
							extra: [{
								type: 'select',
								rules: ['require'],
								placeholder: '请选择医生审核'
							}]
						}, {
							type: 'radio',
							label: '评估表不通过',
							value: {
								target_sc_status: 20,
								target_order_status: -11
							},
							extra: [{
								type: 'select',
								rules: ['require'],
								placeholder: '请选择不通过原因'
							}, {
								type: 'textarea',
								placeholder: '请详细说明'
							}]
						}]
					}
					res['evaluation-approve'] = res['evaluation-service']
					res.text = '就诊评估进行中'
					break;
				case 12:
					res.current_order_status_text = '已通过'
					res['evaluation-service'] = {
						text: '评估单已通过审核，患者可持二维码到院预约挂号。',
						option: [{
							type: 'radio',
							value: {
								target_sc_status: 21,
								target_order_status: 20
							},
							label: '确认患者已预约挂号'
						}]
					}
					res['evaluation-approve'] = {
						text:'该服务单不需要您进一步操作。'
					}
					res.text = '就诊评估已通过'
					break;
				case 13:
					res.current_order_status_text = '已评估'
					res['evaluation-service'] = {
						text: '该服务单不需要您进一步操作',
						option: [{
							type: 'radio',
							value: {
							},
							label: ''
						}]
					}
					res['evaluation-approve'] = {
						text:'该服务单不需要您进一步操作。'
					}
					res.text = '就诊评估已评估'
					break;
				case -11:
					res.current_order_status_text = '未通过'
					res['evaluation-service'] = {
						text: '患者资料未通过，如果患者后期补全资料，请重新指派医生审核',
						option: [{
							type: 'radio',
							label: ' 资料齐全，指派给医生审核',
							value: {
								target_sc_status: 20,
								target_order_status: 11
							},
							extra: [{
								type: 'select',
								placeholder: '请选择医生审核'
							}]
						}]
					}
					res['evaluation-approve'] = {
						text: '该服务单不需要您进一步操作。'
					}
					res.text = '就诊评估未通过'
					break;
				case -12:
					res.current_order_status_text = '已取消'
					res.text = '就诊评估已取消'
					break;
				default:
					break;
			}
			break;
		case 21:
			res.sc_status_text = '挂号就诊'
			switch(Number(obj.current_order_status)) {
				case -12:
					res.current_order_status_text = '已取消'
					res.text = '预约挂号已取消'
					break;
				case 20:
					res.current_order_status_text = '预约挂号'
					res['evaluation-service'] = {
						text: '患者已预约挂号，是否已来院就诊？',
						option: [{
							type: 'radio',
							value: {
								target_sc_status: 21,
								target_order_status: 21
							},
							label: '确认患者已门诊就诊'
						}]
					}
					res['evaluation-approve'] = {
						text: '该服务单不需要您进一步操作。'
					}
					res.text = '已预约挂号'
					break;
				case 21:
					res.current_order_status_text = ' 门诊已就诊'
					res['evaluation-service'] = {
						text: '	患者已完成门诊就诊，如果患者不需要住院，不需要下一步操作；如果患者需住院，请选择：',
						option: [{
							type: 'radio',
							value: {
								target_sc_status: 22,
								target_order_status: 30
							},
							label: '患者需住院，已加入预约排队'
						}, {
							type: "radio",
							value: {
								target_sc_status: 22,
								target_order_status: 31
							},
							label: "患者已经预约住院"
						}]
					}
					res['evaluation-approve'] = {
						text: '该服务单不需要您进一步操作。'
					}
					res.text = '门诊已就诊'
					break;
			}
			break;
		case 22:
			res.sc_status_text = '住院预约'
			switch(Number(obj.current_order_status)) {
				case -12:
					res.current_order_status_text = '已取消'
					res['evaluation-service'] = {
						text: '确认患者已住院就诊'
					}
					res['evaluation-approve'] = {
						text: '该服务单不需要您进一步操作'
					}
					res.text = '住院预约已取消'
					break;
				case 30:
					res.current_order_status_text = '住院排队中'
					res['evaluation-service'] = {
						text: '患者已加入住院预约排队，是否已成功预约住院时间？',
						option: [{
							type: 'radio',
							value: {
								target_sc_status: 22,
								target_order_status: 31
							},
							label: '确认患者已预约住院'
						}]
					}
					res['evaluation-approve'] = {
						text: '该服务单不需要您进一步操作。'
					}
					res.text = '住院排队中'
					break;
				case 31:
					res.current_order_status_text = '住院预约成功'
					res['evaluation-service'] = {
						text: '患者已预约住院，是否已入院？',
						option: [{
							type: 'radio',
							value: {
								target_sc_status: 22,
								target_order_status: 32
							},
							label: '确认患者已住院就诊'
						}]
					}
					res['evaluation-approve'] = {
						text: '该服务单不需要您进一步操作'
					}
					res.text = '住院预约成功'
					break;
				case 32:
					res.current_order_status_text = '到院就诊'
					res.text = '已到院就诊'
					break;
			}
			break;
		default:
			break;
	}
	switch(Number(obj.current_order_type)) {
		case 10:
			res.current_order_type_text = '诊前评估'
			break;
		case 11:
			res.current_order_type_text = '挂号就诊'
			break;
		case 12:
			res.current_order_type_text = '住院预约'
			break;
		default:
			break;
	}
	return res
};
//服务组合类型对应
function sc_status(val) {
	var result
	switch(Number(val)){
		case 20:
			result = '诊前评估'
			break;
		case 21:
			result = '挂号就诊'
			break;
		case 22:
			result = '住院预约'
			break;
		default:
			break;
	}
		return result
}
//订单状态
function order_status(val){
	var order
	switch(Number(val)){
		case 10:
			order = '已提交'
			break;
		case 11:
			order = '待确认'
			break;
		case 12:
			order = '已通过'
			break;
		case 13:
			order = '已评估'
			break;
		case -11:
			order = '未通过'
			break;
		case -12:
			order = '已取消'
			break;
		case 20:
			order = '预约挂号'
			break;
		case 21:
			order = '门诊已就诊'
			break;
		case 30:
			order = '住院排队'
			break;
		case 31:
			order = '住院预约成功'
			break;
		case 32:
			order = '到院就诊'
			break;
		default:
			break;
	}
		return order
}
export default {
	parse: parseFn,
	sc_status: sc_status,
	order_status: order_status
}